package ascii;

import java.util.Random;

public class Shuffled {

	static String shuffled(String s) {
	    char[] a = s.toCharArray();
	    final int N = a.length;
	    Random r = new Random();
	    for (int i = N - 1; i >= 0; i--) {
	        int j = r.nextInt(i + 1);
	        swap(a, i, j);
	    }
	    return new String(a);
	}
	static void swap(char[] a, int i, int j) {
	    char t = a[i];
	    a[i] = a[j];
	    a[j] = t;
	}


	public static void main(String[] args){
		String text = "stackoverflow";
		System.out.println("Before shuffled: " + text + "\n" + "Shuffled:");
	    for (int i = 0; i < 10; i++) {
	        System.out.println(shuffled(text));
	    }
	}
}